<template>
  <div class="app-container flex1 flex-col over-hidden">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
      <el-form-item label="供应商名称" prop="supplierName">
        <el-input
          v-model="queryParams.supplierName"
          placeholder="请输入供应商名称"
          clearable
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      
      <el-form-item label="牌号" prop="brand">
        <el-input
          v-model="queryParams.brand"
          placeholder="请输入牌号"
          clearable
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="规格" prop="specifications">
        <el-input
          v-model="queryParams.specifications"
          placeholder="请输入规格"
          clearable
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="日期" prop="documentDate">
        <el-date-picker
          v-model="queryParams.documentDate"
          type="daterange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="flex-shrink-0 mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          size="mini"
          @click="handleExport"
          v-hasPermi="['system:role:add']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <div class="over-hidden">
      <el-table v-loading="loading" :data="supplierList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="日期" prop="statementDate" />
      <el-table-column label="供应商名称" prop="supplierName"/>
      <el-table-column label="商品名称" prop="tradeName" />
      <el-table-column label="产地" prop="placeOrigin" />
      <el-table-column label="牌号" prop="brand" />
      <el-table-column label="规格" prop="specifications" />
      <el-table-column label="数量" prop="quantity" />
      <el-table-column label="件数" prop="number" />
      <el-table-column label="单价" prop="unitPrice" />
      <el-table-column label="金额" prop="amountMoney" />
    </el-table>
    </div>
    

    <pagination
      class="text-center bgfff pd10"
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    
    <div slot="footer" class="dialog-footer">
        <el-button @click="cancel">取 消</el-button>
    </div>

  </div>
</template>

<script>
import { utils } from "@/utils/utils";
export default {
  name: "Detail",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 角色表格数据
      supplierList: [
          {
             id:1,//id
             statementDate:'2022-04-19', //日期
             supplierName:'深圳一飞冲天有限公司',//供应商名称
             tradeName:'好产品',//商品名称
             placeOrigin:'深圳',//产地
             brand:'145241',//牌号
             specifications:'abc',//规格
             quantity:'10',//数量
             number:'5',//件数
             unitPrice:'5000',//单价
             amountMoney:'10000',//金额
          }
      ],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        supplierName: undefined,
        brand: undefined,
        specifications:undefined,
        documentDate:undefined,
      },
      headerName:['日期','供应商名称','商品名称','产地','牌号','规格','数量','件数','单价','金额'],
      headerList:['statementDate','supplierName','tradeName','placeOrigin','brand','specifications','quantity','number','unitPrice','amountMoney'],
    };
  },
  created() {
    this.getList();
  },
  methods: {
    handleExport(){
      utils.exportExcel(this.headerName,this.headerList,this.supplierList,'账单明细');
    },
    cancel(){
      this.$emit('cancel',false);
    },
    getList() {
        this.loading = false;
        this.total = 10;
    },
    reset() {
      if (this.$refs.menu != undefined) {
        this.$refs.menu.setCheckedKeys([]);
      }
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!=1
      this.multiple = !selection.length
    },
  }
};
</script>
<style scope  lang="scss" >
.app-container{
  .dialog-footer{
      text-align: center;
  }
}
</style>